package com.cheer.vo;

import cn.hutool.core.date.DateUtil;
import com.cheer.entity.LecCourseEntity;
import com.cheer.entity.LecTeacherEntity;
import com.google.common.collect.Maps;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;


/**
 * 课程导出
 */
@Data
public class LecCourseExportVO {

    private String title;

    private String lectureTime;

    private String name;

    private String address;

    private String count;

    private String department;

    private String note;

    public static final Map<String, String> headerAlias = Maps.newLinkedHashMap();

    static{
        headerAlias.put("title","宣讲主题");
        headerAlias.put("lectureTime","宣讲时间");
        headerAlias.put("name","讲师");
        headerAlias.put("address","宣讲地址");
        headerAlias.put("count","人数");
        headerAlias.put("department","主办单位");
        headerAlias.put("note","备注信息");
    }

    public static List<LecCourseExportVO> convertTOLecCourseExportVO( Map<Integer, List<LecTeacherEntity>> idMapLecTeacherEntitys,
                                                                      List<LecCourseEntity> list ){

        List<LecCourseExportVO> lecCourseExportVOS = list.stream().map(entity -> {
            LecCourseExportVO lecCourseExportVO = new LecCourseExportVO();
            BeanUtils.copyProperties(entity, lecCourseExportVO);
            lecCourseExportVO.setName(idMapLecTeacherEntitys.get(entity.getTeacherId()).get(0).getName());
            lecCourseExportVO.setLectureTime(DateUtil.formatDate(entity.getStartTime()) + " " + DateUtil.formatTime(entity.getStartTime()) +
                    "-" + DateUtil.formatDate(entity.getEndTime()) + " " + DateUtil.formatTime(entity.getEndTime()));
            lecCourseExportVO.setCount(String.valueOf(entity.getCount()));
            return lecCourseExportVO;
        }).collect(Collectors.toList());

        return lecCourseExportVOS;
    }



}
